package com.ljc.dao;

import com.ljc.entity.College;
import com.ljc.vo.CollegeSearch;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import java.util.List;
@Repository
@Mapper
public interface CollegeDao {
    @Select("select * from college where dean_id=#{deanId}")
    List<College> getCollege(int deanId);

    List<College> searchCollege(CollegeSearch collegeSearch);

    @Select("select * from college where name=#{name}")
    College findByName(String name);

    @Insert("insert into college(name,address,principal,establish,description,dean_id) " +
            "values(#{name},#{address},#{principal},#{establish},#{description},#{deanId})")
    void addCollege(College college);

    @Select("select * from college where id=#{id}")
    College getCollegeById(int id);

    @Update("update college set name=#{name},address=#{address},principal=#{principal},establish=#{establish},description=#{description} where id=#{id}")
    void updateCollege(College college);

    @Update("update college set deleted=1 where id=#{id}")
    void delete(int id);
}
